import Vue from 'vue'
import {fetch, post, put, del, patch} from './index'

Vue.prototype.$post = post
Vue.prototype.$fetch = fetch
Vue.prototype.$patch = patch
Vue.prototype.$put = put
Vue.prototype.$del = del

export const _baseUrl = 'http://127.0.0.1:9090/'

//格式化参数
export function parseParam(data) {
  try {
    let tempArr = []
    for (let i in data) {
      let key = encodeURIComponent(i)
      let value = encodeURIComponent(data[i])
      tempArr.push(key + '=' + value)
    }
    let urlParamsStr = tempArr.join('&')
    return urlParamsStr
  } catch (err) {
    return ''
  }
}
